<?php
    $top_menu_1 = TRUE;
    $top_menu_2 = FALSE;
    $top_menu_3 = FALSE;
    $top_menu_4 = FALSE;
    $top_menu_5 = FALSE;
    $top_menu_6 = FALSE;
    $top_menu_7 = FALSE;
    
    include('header.php');
    
    $rss = $db->query('SELECT * FROM hs_category ORDER BY c_id');
    $catList = '';
    $catListSlide = '';
    while ($line = $db->fetchNextObject($rss)){
        $catList .= '<li><a href="product.php?id='.$line->c_id.'" title="'.$line->c_name.'">'.$line->c_name.'</a></li>';
        $catListSlide .= '<li><a href="product.php?id='.$line->c_id.'" title="'.$line->c_name.'"><img src="images/products/category/'.$line->c_id.'/'.$line->c_img1.'" alt="'.$line->c_name.'" ></a></li>';
    }
    
    $rss = $db->query('SELECT * FROM hs_product WHERE p_active=1 GROUP BY c_id');
    $productList = '';
    $x = 0;
    while ($line = $db->fetchNextObject($rss)){
        $class='';
        if((($x++)%4)==0){
            $class='home_product_block_first';
        }
        
        $desc = strip_tags($line->p_detail);
        
        if($line->p_img!='' AND file_exists(APPPATH.'/images/products/product/'.$line->p_id.'/'.$line->p_img)){
            $productImg = URL.'/images/products/product/'.$line->p_id.'/'.$line->p_img;
        }else{
            $productImg = URL.'/images/noimg.jpg';
        }
        
        $productList .= <<<productList
                <div class="home_product_block {$class}">
                    <div class="home_product_block_img">
                        <a href="function/load_product.php?id={$line->p_id}" title="" class="aFancyBox"><img src="{$productImg}" alt="{$line->p_name}" class="img_link" /></a>
                    </div>
                    <div class="home_product_block_desc">
                        {$desc}
                    </div>
                    <div class="home_product_block_addcart">
                        <a href="cart.php?id={$line->p_id}" title="add to cart">add to cart</a>
                    </div>
                </div>
productList;
    }
?>
        <div id="home_top">
            <div id="home_product_cat_list">
                <ul>
                    <?php echo $catList; ?>
                    <div class="clear">&nbsp;</div>
                </ul>
            </div>
            <div id="home_product_cat_slide_ctrl">
                <img src="images/prev_bt.jpg" alt="Hongchiao" class="img_link" id="prev_bt" />
                <img src="images/next_bt.jpg" alt="Hongchiao" class="img_link" id="next_bt" />
                <div class="clear">&nbsp;</div>
            </div>
        </div>
        <div class="clear">&nbsp;</div>
        <div id="home_product_cat_slide">
            <ul>
                <?php //echo $catListSlide; ?>
                <li><img src="images/temp/gallery-slide2_01.jpg" /></li>
                <li><img src="images/temp/gallery-slide2_02.jpg" /></li>
                <li><img src="images/temp/gallery-slide2_03.jpg" /></li>
                <li><img src="images/temp/gallery-slide2_04.jpg" /></li>
                <li><img src="images/temp/gallery-slide_01.jpg" /></li>
                <li><img src="images/temp/gallery-slide_02.jpg" /></li>
                <li><img src="images/temp/gallery-slide_03.jpg" /></li>
                <li><img src="images/temp/gallery-slide_04.jpg" /></li>
            </ul>
        </div>
<?php
    include('sidebar1.php');
?>
            <div id="main_content" class="home_content">
                <a href="product.php" title="Product"><img src="images/home_product_title.jpg" alt="Product" id="home_product_title" class="img_link" /></a>
                
                <?php echo $productList; ?>
                
                <div class="clear">&nbsp;</div>
            </div>
            <div class="clear">&nbsp;</div>
<?php
    include('footer.php');
?>
<script type="text/javascript" src="js/jcarousellite_1.0.1.min.js"></script>
<script type="text/javascript" src="js/jquery.tinyscrollbar.min.js"></script>
<script>
    $(function() {
        $("#home_product_cat_slide").jCarouselLite({
            btnNext: "#next_bt",
            btnPrev: "#prev_bt",
            visible:4
        });
        
        $("a.aFancyBox").fancybox({
                'speedIn'		:	600, 
                'speedOut'		:	200, 
                'overlayShow'	:	false,
                'opacity' : true,
                'transitionIn'	:	'elastic',
                'transitionOut'	:	'elastic',
                'padding' : 0,
                'margin' : 0,
                'showCloseButton' : false,
		onComplete	:	function() {
		    $('#product_detail__').tinyscrollbar();
		}
        });
    });
    
    function fancybox_close(){
        $.fancybox.close();
    }
</script>
